<?php
/*parameters
 * first - firmAlias
 * second - beerAlias
 */
require_once("class/bpBeer.class.php");
if (isset($_REQUEST["second"])) {
    $beerAlias = $_REQUEST["second"];
    $firmAlias = $_REQUEST["first"];
    $aBeer = bpBeer::getBeer($firmAlias, $beerAlias);
    if (USER_STATUS) {
        $sBeerUserVote = bpVote::hasUserVoted(USER_ID, "beer_beer", $aBeer["id"]);
        $smarty->assign("sBeerUserVote", $sBeerUserVote);
    }
    $smarty->assign("aBeer", $aBeer);
    $smarty->display("beer/beer_firm_beer.tpl");
} elseif(isset($_REQUEST["first"])) {
    $firmAlias = $_REQUEST["first"];
    $aFirm = bpBeer::getFirmArray($firmAlias, true);
    $smarty->assign("aFirm", $aFirm);
    $aBeers = bpBeer::getBeerByFirm($aFirm["id"]);
    if (USER_STATUS) {
        $aBeerId = array();
        foreach ($aBeers as $aTempBeer) {
            $aBeerId[] = $aTempBeer["id"];
        }
        $aBeerUserVotes = bpVote::getVotingBlockArray(USER_ID, "beer_beer", $aBeerId); 
        $smarty->assign("aBeerUserVotes", $aBeerUserVotes);
    }
    $smarty->assign("aBeers", $aBeers);
    $smarty->assign("spFirm", PATH_TO_IMAGES_BEER_FIRM);
    $smarty->display("beer/beer_firm.tpl");
} else {
    $aFirms = bpBeer::getFirmArray();
    $smarty->assign("aFirms", $aFirms);
    $smarty->assign("spFirm", PATH_TO_IMAGES_BEER_FIRM);
    $smarty->display("beer/beer_firms.tpl");
}

?>